package com.cskaoyan.wordmemorize.controller.app;

import com.cskaoyan.wordmemorize.common.result.Result;
import com.cskaoyan.wordmemorize.dto.admin.PageDTO;
import com.cskaoyan.wordmemorize.dto.app.AppGoodsDTO;
import com.cskaoyan.wordmemorize.request.GoodsPageRequest;
import com.cskaoyan.wordmemorize.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * APP端商品控制器
 * 提供商品相关的接口服务
 */
@RestController
@RequestMapping("product")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    /**
     * 获取商品列表
     *
     * @param request 查询参数，包含分页参数和商品类型等信息
     * @return 商品列表分页数据
     */
    @GetMapping("")
    public Result<PageDTO<AppGoodsDTO>> getGoodsList(GoodsPageRequest request) {
        // 调用服务层获取数据
        PageDTO<AppGoodsDTO> result = goodsService.getAppGoodsPage(request);
        return Result.ok(result);
    }
}
